<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function fn(x, y) {
            console.log(this);
            console.log(x + y);
        }

        var o = {
                name: 'adele'
            }
            // fn(1, 2)
            // fn.call()
            // call(this改变的对象，参数1，参数2)
        fn.call(o, 1, 2) //输出：{name: "adele"} 
            // call函数的作用：1.可以调用普通函数 2.可以改变this的指向



            
        function Product(name, price) {
            this.name = name;
            this.price = price;
            console.log(this);
        }

        function Food(name, price) {
            Product.call(this, name, price);
            this.category = 'food';
        }

        function Toy(name, price) {
            Product.call(this, name, price);
            this.category = 'toy';
        }

        var cheese = new Food('feta', 5);
     
        var fun = new Toy('robot', 40);
    </script>
</body>

</html>